<?php 
require('./lib/init.php');
if(empty($_POST)){
	require(ROOT.'/view/admin/login.html');
}else{
	$user['name'] = addslashes(trim($_POST['name']));
	if(empty($user['name'])){
		error('用户名不能为空');
	}

	$user['password'] = trim($_POST['password']);
	if(empty($user['password'])){
		error('密码不能为空');
	}
	/*$sql = "select * from user where name='$user[name]' and password='$user[password]'";*/
	$sql = "select * from user where name='$user[name]'";
	$user1 = mGetRow($sql);
	if(empty($user1)){
		error('用户名错误');
	}elseif(md5($user['password'].$user1['salt']) !== $user1['password']){
		error('密码错误');
	}else{
		setcookie('name',$user['name']);
		header('Location:artlist.php');
	}
}

